<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
  $_SESSION['MM_id_target']=NULL;
	$_SESSION['MM_aut_target']=NULL;
	$_SESSION['MM_nmb_target']=NULL;
	$_GET['redirect']=NULL;
	$_SESSION['MM_id_candidato']=NULL;
	$_SESSION['MM_id_empresa']=NULL;
	
  $logoutGoTo = "../private/login.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../private/login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
#Inicia redirccionamiento
$redirect=NULL;
#Verifica la convocatoria para identificar la pantalla desde donde se hace la solicitud.
if($_GET['redirect']=="EMPLEATE"){$redirect="report_riv_emp.php";}else 
if($_GET['redirect']=="EXPERIMENTA"){$redirect="report_riv_exp.php";}else 
if($_GET['redirect']=="MI PRIMERA EMPRESA"){$redirect="report_riv_mpe.php";}else
if($_GET['redirect']=="BECAS VINCULACION"){$redirect="report_riv_bv.php";}else{$redirect="report_rov_candidatos.php";}
#Actualizacion y Redireccionamiento para pantallas de asignacion de beneficiarios de programas distintos a mi primera empresa, el valor en el GET[rel] es la relación de la IES y la Empresa
if(isset($_GET['rel'])&&$_GET['redirect']!="MI PRIMERA EMPRESA"&&!isset($_GET['id_convocatoria'])){
	$objId=base64_decode($_GET['rel']);
	require_once('../Connections/miportal.php'); 
	mysql_select_db($database_miportal, $miportal);
	$updateSQL = sprintf("UPDATE cor_ben_ies_emp SET tp_status_validacion=1 WHERE id_numRelacion=%s", $objId);
	$update_rel = mysql_query($updateSQL, $miportal) or die(mysql_error());
	
	header("Location: ".$redirect); 
#Actualizacion y Redireccionamiento para pantallas de asignacion de beneficiarios de programa Mi primera empresa, el valor en el GET[rel] es la relación de la IES y la Primaria
}else if(isset($_GET['rel'])&&$_GET['redirect']=="MI PRIMERA EMPRESA"&&!isset($_GET['id_convocatoria'])){
	$objId=base64_decode($_GET['rel']);
	require_once('../Connections/miportal.php'); 
	mysql_select_db($database_miportal, $miportal);
	$updateSQL = sprintf("UPDATE cor_ben_ies_primaria SET tp_status_validacion=1 WHERE id_cor_ben_ies_primaria=%s", $objId);
	$update_rel = mysql_query($updateSQL, $miportal) or die(mysql_error());
	
	header("Location: ". $redirect); 

}
#Actualización de estatus a Expediente cuando se realiza una desasignacion de candidato a Empresa
if(isset($_GET['rel'])&&isset($_GET['id_convocatoria'])&&$_GET['id_convocatoria']!=20&&isset($_GET['id_ben'])){
	$objId=base64_decode($_GET['rel']);
	$id_cor_candidato=base64_decode($_GET['id_ben']);
	require_once('../Connections/miportal.php'); 
	mysql_select_db($database_miportal, $miportal);
	$updateSQL = sprintf("DELETE FROM cor_ben_ies_emp WHERE id_numRelacion=%s", $objId);
	$update_rel = mysql_query($updateSQL, $miportal) or die(mysql_error());
	$updateSQL = sprintf("UPDATE cor_candidato SET tp_stat_registro='EXPEDIENTE' WHERE id_cor_candidato=%s", $id_cor_candidato);
	$update_rel = mysql_query($updateSQL, $miportal) or die(mysql_error());
	
	header("Location: ".$redirect); 
#Actualización de estatus a Expediente cuando se realiza una desasignacion de candidato a Primaria
}else if(isset($_GET['rel'])&&isset($_GET['id_convocatoria'])&&$_GET['id_convocatoria']==20&&isset($_GET['id_ben'])){
	$objId=base64_decode($_GET['rel']);
	$id_cor_candidato=base64_decode($_GET['id_ben']);
	require_once('../Connections/miportal.php'); 
	mysql_select_db($database_miportal, $miportal);
	$updateSQL = sprintf("DELETE FROM cor_ben_ies_primaria  WHERE id_cor_ben_ies_primaria=%s", $objId);
	$update_rel = mysql_query($updateSQL, $miportal) or die(mysql_error());
	$updateSQL = sprintf("UPDATE cor_candidato SET tp_stat_registro='EXPEDIENTE' WHERE id_cor_candidato=%s", $id_cor_candidato);
	$update_rel = mysql_query($updateSQL, $miportal) or die(mysql_error());
	
	header("Location: ". $redirect); 

}




?>
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximun-scale=1">
<title>FUNDACIÓN EDUCACIÓN SUPERIOR-EMPRESA</title>
<!--Hoja de estilo principal-->
<link href="../css/styletd2.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="shortcut icon" href="stylesheet/img/devil-icon.png"> 
<link rel="stylesheet" type="text/css" href="../css/mos-style.css">
<link rel="stylesheet" type="text/css" href="../css/menu.css"><!--Pemanggilan gambar favicon-->
 <!--pemanggilan file css-->
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
</head>
<body>

 <header>
    <div id="background"></div><!--BackGround Menu header-->
		<div class="img_header_logo"></div>
		<span class="img_header_logo"><a href="http://fese.org.mx"><img src="../images/fese/FESE_home_logo.png"  height="90" alt="FESE" align="bottom" /></a></span>
		<div class="img_header_logo"></div>
		<?php include_once('../include/riv_nav.php');?>
</header>

<center>
<div id="boxcontainer">
<div id="container">
  <p>&nbsp;</p>
  <h2>REGISTRO SIN VALIDAR</h2>
  <p>&nbsp;</p>
<p>&nbsp;</p>
  <div id="dinamicContaint">
  
  </div><!--dinamicContaint-->
  <p>&nbsp;</p>
</div><!--Container-->
<div id="rightContainer">
    <div id="Bienvenida">
    <div id="cuadro">
    <h1>Bienvenido</h1>
    </div>
    
    <div >
    <br>
            <?php echo $_SESSION['MM_UsName'] ?><br><br>
            <?php echo $_SESSION['MM_nmb_target'] ?><br>
            <a href="<?php echo $logoutAction ?>">Salir</a>
            </div>
    </div>
    <br style="clear:both"/>
    <div id="convocatoria">
    <div id="cuadro">
    <h1>Convocatoria</h1>
    </div>
    <br>
    <?php 
    if(isset($_GET['redirect'])&$_GET['redirect']=="VIGENTES"){
        echo "<select name=\"slConvocatoria\">
        <option selected=\"selected\">Seleccione</option>
        <option value=\"empleate\">Empleate</option>
        <option value=\"experimenta\">Experimenta</option>
        <option value=\"mpe\">Mi Primera Empresa</option>
        <option value=\"vecas_vinculacion\">Vecas Vinculación</option>
        </select>
        "	;
    }else{
    echo $_GET['redirect'];}
    ?>
    
    </div>
</div><!--contenedor derecho-->


</div><!--Boxcontainer-->
</center>
  
  
</body>
</html>

